package top.lyc829.leetcode.T160;


class ListNode {
    int val;
    ListNode next;

    ListNode(int x) {
        val = x;
        next = null;
    }
}

public class Solution {
    public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
        ListNode headB1 = null;
        while (headA != null) {
            headB1 = headB;
            while (headB1 != null) {
                if (headA == headB1) {
                    return headA;
                }
                headB1 = headB1.next;
            }
            headA = headA.next;
        }

        return null;
    }
}
